package com.tenement.controller;

import com.tenement.common.Axios;
import com.tenement.entity.HouseUser;
import com.tenement.enums.RespBusiness;
import com.tenement.service.HouseUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@Api(tags = "房屋住户关系表")
@RequestMapping("/houseUser")
public class HouseUserController {

    private final HouseUserService houseUserService;

    @ApiOperation("审核住户")
    @PutMapping(value = "audit")
    public Axios audit(@RequestBody HouseUser houseUser) {
        return houseUserService.audit(houseUser) ? Axios.success(RespBusiness.SUCCESS) : Axios.error(RespBusiness.FAIL);
    }

    @ApiOperation("解除房屋绑定")
    @DeleteMapping("unbind")
    public Axios unbind(@RequestBody HouseUser houseUser) {
        return houseUserService.unbind(houseUser) > 0 ? Axios.success(RespBusiness.SUCCESS) : Axios.error(RespBusiness.FAIL);
    }

}
